package com.livi.tools.cas_general_backend.entity.response;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author Livi Luo
 */
@Data
@Accessors(chain = true)
public class Res {

    private Boolean status;

    private Integer code;

    private String msg;

    public static Res success() {
        return success(ResStatusEnum.success);
    }

    public static Res success(ResStatusEnum status) {
        Res res = new Res();
        res.setStatus(true);
        res.setCode(status.getCode());
        res.setMsg(status.getMsg());
        return res;
    }

    public static Res fail() {
        return fail(ResStatusEnum.fail, null);
    }

    public static Res fail(String msg) {
        return fail(ResStatusEnum.fail, msg);
    }

    public static Res fail(ResStatusEnum status) {
        return fail(status, null);
    }

    public static Res fail(ResStatusEnum status, String msg) {
        Res res = new Res();
        res.setStatus(false);
        res.setCode(status.getCode());
        res.setMsg(msg != null ? msg : status.getMsg());
        return res;
    }

}
